import { PluginFunction, default as VueImport } from 'vue';
import { appInitialize } from './app-initialize';
// 组件
import { iBizCalendarVue } from './components/ibiz-calendar';

// 安装记录，避免重复安装
let Vue: typeof VueImport;

// iBiz插件安装
export const install: PluginFunction<any> = (_Vue: typeof VueImport) => {
    if (Vue && _Vue === Vue) {
        if (process.env.NODE_ENV !== 'production') {
            console.error(
                '[iBizComponents] already installed. Vue.use(iBizComponents) should be called only once.'
            );
        }
        return;
    }
    Vue = _Vue;
    // Vue排除组件
    Vue.config.ignoredElements.push(/^ibiz-/);
    // 安装原生组件
    appInitialize();
    // 安装Vue组件
    Vue.component('ibz-calendar-vue', iBizCalendarVue);
}
